<template>
  <div class="xiaoxi">
    <div class="xiaoxi-header">
      <img @click="back()" class="router-span" src="../../assets/img/shouye/header-xinpin/back.png"/>
      <span>消息中心</span>
    </div>
    <ul class="xiaoxi-ul">
      <li>
        <h3>2018年3月1日22:22:22</h3>
        <div class="xiaoxi-tuijian">
          <h4>新品推荐</h4>
          <div class="xinpin">
            <img src="../../assets/img/shouye/shouye-xiaoxi/huo.png" alt="">
            <p>新品上市了!时间不多了,赶紧行动起来吧!</p>
          </div>
          <div class="gengduo">
            <p>查看更多</p>
            <span> > </span>
          </div>
        </div>
      </li>
      <li>
        <h3>2018年3月1日22:22:22</h3>
        <div class="xiaoxi-tuijian">
          <h4>安全提醒</h4>
          <div class="xinpin">
            <img src="../../assets/img/shouye/shouye-xiaoxi/huo.png" alt="">
            <p>新品上市了!时间不多了,赶紧行动起来吧!</p>
          </div>
        </div>
      </li>
      <li>
        <h3>2018年3月1日22:22:22</h3>
        <div class="xiaoxi-tuijian">
          <h4>收货啦</h4>
          <div class="xinpin">
            <img src="../../assets/img/shouye/shouye-xiaoxi/huo.png" alt="">
            <p>新品上市了!时间不多了,赶紧行动起来吧!</p>
          </div>
        </div>
      </li>
    </ul>
    <div class="up" @click="toTop()" v-if="isUP">
      <img src="../../assets/img/shouye/tuijian-xuanliyanzhuang/toTop.png"/>
    </div>
  </div>
</template>
<script>
  export default {
    data () {
      return {
        isUP: false
      }
    },
    methods: {
      back() {
        this.$router.go(-1);
      },
      toTop () {
        if(document.documentElement){
          document.documentElement.scrollTop = 0;
        }else{
          document.body.scrollTop = 0;
        }
      },
      menu() {
        this.scroll = document.documentElement.scrollTop || document.body.scrollTop;
        if(this.scroll > 0){
          //显示 a 标签
          this.isUP = true;
        }else{
          //隐藏 a 标签
          this.isUP = false;
        }
      },
      top () {
        window.scrollTo(0,0)
      }
    },
    mounted() {
      window.addEventListener('scroll', this.menu)
    },
    created () {
      this.top();
    }
  }
</script>
<style scoped>
  .xiaoxi {
    height: 30rem;
    background: #f2f2f2;
    position: relative;
    width: 100%;
    padding-top: 2rem;
  }
  .xiaoxi-header {
    width: 100%;
    height: 2rem;
    background: #e53e42;
    display: flex;
    text-align: center;
    line-height: 2rem;
    position: fixed;
    top: 0;
    left: 0;
  }
  .xiaoxi-header span {
    color: #ffffff;
    font-size: 0.8rem;
    flex: 1;
  }
  .xiaoxi-header .router-span{
    width: 0.6rem;
    height: 1rem;
    margin-left: 0.5rem;
    margin-top: 0.5rem;
  }
  .xiaoxi-ul h3 {
    text-align: center;
    font-family: MicrosoftYaHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    line-height: 2rem;
    letter-spacing: 0rem;
    color: #808080;
  }
  .xiaoxi-ul .xiaoxi-tuijian {
    background: #fff;
    width: 90%;
    border: solid 1px #cccccc;
    border-radius: 0.2rem;
    margin: 0 auto;
    padding: 0.2rem 0.1rem;
  }
  .xiaoxi-tuijian h4 {
    font-family: MicrosoftYaHei;
    font-size: 0.7rem;
    font-weight: normal;
    font-stretch: normal;
    line-height: 1rem;
    letter-spacing: 0rem;
    color: #4d4d4d;
  }
  .xiaoxi-tuijian .xinpin {
    display: flex;
    border-bottom: 1px solid #ccc;
  }
  .xiaoxi-tuijian .xinpin img {
    padding: 0.3rem;
    width: 3rem;
    height: 3rem;
    flex:1;
  }
  .xiaoxi-tuijian .xinpin p {
    padding: 0.3rem;
    flex: 3;
    font-family: MicrosoftYaHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    letter-spacing: 0rem;
    color: #808080;
  }
  .gengduo {
    display: flex;
  }
  .gengduo p, .gengduo span{
    flex: 1;
    padding: 0.3rem;
    font-family: MicrosoftYaHei;
    font-size: 0.6rem;
    font-weight: normal;
    font-stretch: normal;
    letter-spacing: 0rem;
    color: #808080;
  }
  .gengduo span {
    text-align: right;
  }
  .up {
    width: 1.5rem;
    position: fixed;
    bottom: 0;
    right: 0.3rem;
  }
  .up img {
    width: 100%;
  }
</style>
